how to find the frequency of characters in the string